package com.rgp.serviceprice.controller;

import com.rgp.internalcommon.dto.FareTypeDto;
import com.rgp.internalcommon.dto.ResponseResult;
import com.rgp.internalcommon.dto.TollRuleDto;
import com.rgp.internalcommon.response.FareVersionResponse;
import com.rgp.serviceprice.service.TollRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author nhp
 * @version 1.0
 * @description TODO
 * @date 2024-04-21 11:46
 */
@RestController
public class TollRuleController {

    @Autowired
    private TollRuleService tollRuleService;

    @PostMapping("/price-rule/add")
    public ResponseResult addTollRule(@RequestBody TollRuleDto tollRuleDto){
        return tollRuleService.addTollRule(tollRuleDto);
    }

    @PutMapping("/price-rule/edit")
    public ResponseResult editTollRule(@RequestBody TollRuleDto tollRuleDto){
        return tollRuleService.editTollRule(tollRuleDto);
    }

    @PostMapping("/price-rule/get-newest-version")
    public ResponseResult<FareVersionResponse> getNewestFareVersion(@RequestBody FareTypeDto fareTypeDto){
        return tollRuleService.getNewestFareVersion(fareTypeDto);
    }

    @PostMapping("/price-rule/if-exists")
    public ResponseResult<Boolean> ifExists(@RequestBody FareTypeDto fareTypeDto){
        return tollRuleService.ifExists(fareTypeDto);
    }
}
